<%--
  User: ercha
  Date: 2015/12/1 18:40
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>注册成功</title>
    <%@include file="../common/component/head.jsp"%>
</head>

<body>
    <p>注册成功！已向您的邮箱发送一封激活邮件。5 分钟有效。如果没有收到激活邮件，点击下面按钮</p>
    <input hidden value="${email}" id="email">
    <button type="button" id="mailBtn">发送激活邮件</button>
</body>
<%@include file="../common/component/foot.jsp"%>
<script src="${ctx}/assets/js/common/common.js" ></script>

<script>
    $(function() {
        var path = window.location.pathname.split("/")[0];
        $('#mailBtn').click(function(){
                    $.ajax({
                        type: "post",
                        url: path+"/sendActiveMail",
                        data: {
                            email: $('#email').val()
                        },
                        //服务器返回数据类型。如果不指定，将自动根据 HTTP 包 MIME 信息来判断
                        dataType: 'json',
                        success: function(data, textStatus){
                            if(data.success){
                                swal({
                                    title: "",
                                    text: "激活邮件发送成功！",
                                    type: "success",
                                    confirmButtonText: "确定"
                                });
                            }
                            else errorMessage(data.msg);
                        },
                        // 通常 textStatus 和 errorThrown 之中只有一个会包含信息
                        error: function(XMLHttpRequest, textStatus, errorThrown){
                            //this：调用本次AJAX请求时传递的options参数
                            errorMessage("发送失败，错误代码： " + XMLHttpRequest.status);
                        }

                    });
                }
        );

    });
</script>
</html>
